const app = getApp();

Component({
  // data: {
  //   selected: 0,
  //   color: "#7A7E83",
  //   selectedColor: "#000000",
  //   list: [
  //       {
  //           "pagePath": "/pages/index/index",
  //           "iconPath": "/images/shouye-weixuanzhong.png",
  //           "selectedIconPath": "/images/shouye-xuanzhong.png",
  //           "text": "首页"
  //       },
  //       {
  //           "pagePath": "/pages/prod/prod",
  //           "iconPath": "/images/shangcheng-weixuanzhong.png",
  //           "selectedIconPath": "/images/shangcheng-xuanzhong.png",
  //           "text": "商城"
  //       },
  //       {
  //           "pagePath": "/pages/cart/cart",
  //           "iconPath": "/images/gouwuche-weixuanzhong.png",
  //           "selectedIconPath": "/images/gouwuche-xuanzhong.png",
  //           "text": "购物车"
  //       },
  //       {
  //           "pagePath": "/pages/my/my",
  //           "iconPath": "/images/gerenzhongxin-weixuanzhong.png",
  //           "selectedIconPath": "/images/gerenzhongxin-xuanzhong.png",
  //           "text": "个人中心"
  //       }
  //   ]
  // },
  data: {
    selected: -1,
    color: "#8a8a8a",
    selectedColor: "#d81e06",
    isiPhoneX: app.globalData.isiPhoneX,
    list: [{
      pagePath: "/pages/index/index",
      iconPath: "icon-shouye-xuanzhong",
      text: "主页"
    }, {
      pagePath: "/pages/prod/prod",
      iconPath: "icon-shangcheng-xuanzhong",
      text: "商城"
    }, {
      pagePath: "/pages/cart/cart",
      iconPath: "icon-gouwuche-xuanzhong",
      text: "购物车"
    }, {
      pagePath: "/pages/my/my",
      iconPath: "icon-gerenzhongxin-xuanzhong",
      text: "我的"
    }]
  },
  pageLifetimes:{
    // 组件所在页面的生命周期声明对象，目前仅支持页面的show和hide两个生命周期
    show:function(){
        console.log('Component-1 pageLifetimes >> Show');
    },
    hide:function(){
        console.log('Component-1 pageLifetimes >> Hide');
    }
  },
  created:function(){
    // 组件生命周期函数，在组件实例进入页面节点树时执行，注意此时不能调用setData
    console.log('Component-1 >> created');
  },
  attached:function(){
      // 组件生命周期函数，在组件实例进入页面节点树时执行。
      console.log('Component-1 >> attached');
  },
  ready:function(){
      // 在组件布局完成后执行，此时可以获取节点信息
      console.log('Component-1 >> ready');
      let that = this;
      app.setThemeSkin(that,function(res){
          that.setData({
            selectedColor: res.skinColor
          });
      });
  },
  moved:function(){
      // 在组件实例被移动到节点树另一个位置时执行
      console.log('Component-1 >> moved');
  },
  detached:function(){
      // 在组件实例被从页面节点树移除时执行
      console.log('Component-1 >> detached');
  },
 
  methods: {
    switchTab(e) {
      const data = e.currentTarget.dataset
      const url = data.path
      // this.setData({
      //   selected: null
      // })
      wx.switchTab({url})
    }
  }
})